import request from '@/utils/request'

// 查询流程分类列表
export function categoryTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/category/table`,
    method: 'post',
    data: query
  })
}

// 查询流程分类
export function categoryGroup() {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/category/dictGroup`,
    method: 'get'
  })
}

export function categoryLoad(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/category/load`,
    method: 'get',
    params: query
  })
}

export function categorySave(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/category/save`,
    method: 'post',
    data: query
  })
}

// 删除流程分类
export function categoryDelete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/category/delete`,
    method: 'post',
    data: query
  })
}

// 查询表单列表
export function formTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/form/table`,
    method: 'post',
    data: query
  })
}

// 加载表单信息
export function formLoad(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/form/load`,
    method: 'get',
    params: query
  })
}

// 保存表单
export function formSave(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/form/save`,
    method: 'post',
    data: query
  })
}

// 删除表单
export function formDelete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/form/delete`,
    method: 'post',
    data: query
  })
}

// 查询模型列表
export function modelTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/model/table`,
    method: 'post',
    data: query
  })
}

// 查询历史模型列表
export function modelHistoryTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/model/historyTable`,
    method: 'post',
    data: query
  })
}

// 读取模型流程图
export function modelXml(modelId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/model/readXml/${modelId}`,
    method: 'get'
  })
}

// 保存模型
export function modelSave(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/model/save`,
    method: 'post',
    data: query
  })
}

// 发布模型
export function modelDeploy(modelId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/model/deploy/${modelId}`,
    method: 'post'
  })
}

// 设置模型最新版本
export function modelLatest(modelId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/model/latest/${modelId}`,
    method: 'post'
  })
}

// 删除模型
export function modelDelete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/model/delete`,
    method: 'post',
    data: query
  })
}

// 查询定义列表
export function definitionTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/definition/table`,
    method: 'post',
    data: query
  })
}

// 查询部署发布列表
export function definitionPublishTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/definition/publish/table`,
    method: 'post',
    data: query
  })
}

// 读取流程图信息
export function definitionXml(definitionId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/definition/xml/${definitionId}`,
    method: 'get'
  })
}

// 修改流程状态
export function definitionChangeState(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/definition/changeState`,
    method: 'get',
    params: query
  })
}

// 删除流程
export function definitionDelete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/definition/delete`,
    method: 'post',
    data: query
  })
}

// 查询我的流程列表
export function processOwnTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/ownTable`,
    method: 'post',
    data: query
  })
}

// 查询待签列表
export function claimTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/claimTable`,
    method: 'post',
    data: query
  })
}

// 查询抄送列表
export function copyTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/copyTable`,
    method: 'post',
    data: query
  })
}

// 查询完成列表
export function finishedTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/finishedTable`,
    method: 'post',
    data: query
  })
}

// 查询待办流程列表
export function todoTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/todoTable`,
    method: 'post',
    data: query
  })
}

// 查询代办任务数量
export function taskTodoCount() {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/todoCount`,
    method: 'post'
  })
}

// 启动流程
export function startTask(definitionId, query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/start/${definitionId}`,
    method: 'post',
    data: query
  })
}

// 加载流程表单
export function processFormData(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/formData`,
    method: 'get',
    params: query
  })
}

// 加载流程关联信息
export function processDetailData(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/processDetailData`,
    method: 'get',
    params: query
  })
}

// 获取下一流程节点代办人
export function nextFlowNode(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/nextFlowNode`,
    method: 'get',
    params: query
  })
}

// 获取下一流程节点
export function flowViewer(procInsId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/flowViewer/${procInsId}`,
    method: 'get'
  })
}

// 委派任务
export function taskDelegate(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/delegate`,
    method: 'post',
    data: query
  })
}

// 转办任务
export function taskTransfer(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/transfer`,
    method: 'post',
    data: query
  })
}

// 审批任务
export function taskComplete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/complete`,
    method: 'post',
    data: query
  })
}

// 驳回任务
export function taskReject(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/reject`,
    method: 'post',
    data: query
  })
}

// 回退任务
export function taskRollback(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/rollback`,
    method: 'post',
    data: query
  })
}

// 获取回退节点
export function taskRollbackList(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/rollback/list`,
    method: 'post',
    data: query
  })
}

// 代签任务
export function taskClaim(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/claim`,
    method: 'post',
    data: query
  })
}

// 撤回任务
export function taskRevoke(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/revoke`,
    method: 'post',
    data: query
  })
}

// 取消任务
export function taskCancel(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/cancel`,
    method: 'post',
    data: query
  })
}

// 删除任务
export function taskDelete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/delete`,
    method: 'post',
    data: query
  })
}

// 删除任务
export function taskInstanceDelete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/workflow/task/instance/delete`,
    method: 'post',
    data: query
  })
}
